<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
	.tree-node {padding:0;}
	img {
		height:50px;
		width:50px;
	}
</style>
<script type="text/javascript">
	$(function() {
		$('#toolbar_articleTable').toolbar({buttons:[
           	{name:'add',iconCls:'icon-add',text:'添加文章'},
       		{name:'reload',iconCls:'icon-reload',text:'刷新'}
      	],handler:handler});
		$('#tag_datagrid_toolbar').toolbar({buttons:[
           	{name:'save_tag',iconCls:'icon-ok',text:'审核通过'},
           	{name:'canl_tag',iconCls:'icon-canle',text:'审核不过'}
      	],handler:handler});
		
	    $('#article_datagrid').datagrid({
	    	url:'pageAudit',
    		pagination:true,
    		singleSelect:true,
    		pageSize:20,
    		rownumbers:false,
    		striped:true,
    		fit:true,
    		fitColumns:true,
    		toorbar:'#toolbar_articleTable',
    		columns:[[
    			{field:'id',title:'编号'},
    			{field:'articleTitle',title:'文章标题'},
        		{field:'userName',title:'作者'},
        		{field:'articleType',title:'类型',formatter:function(v,r,i){
        			var type ="";
        			if(r.articleType == "1"){type ="文章"}else if(r.articleType == "3"){type ="音频"}else if(r.articleType == "5"){type="视频"}else if(r.articleType == "7"){type="话题pk"}
        			return type;
        		}},
        		{field:'markPublish',title:'发布标记'},
        		{field:'countView',title:'浏览量'},
        		{field:'countPraise',title:'点赞量'},
        		{field:'countShare',title:'分享量'},
        		{field:'countCollect',title:'收藏量'},
        		{field:'markAudit',title:'审核标记',formatter:function(v,r,i){
        			var audit='未审核';
        			if(r.markAudit == '3'){
        				audit='审核未通过';
        			}else if(r.markAudit == '5'){
        				audit='审核通过';
        			}
        			return audit;
        		}},
        		{field:'enabled',title:'是否可用',formatter:function(v,r,i){
        			var enab = '否';
        			if(r.enabled){
        				enab = '是'
        			}
        			return enab;
        		}},
        		{field:'createdDt',title:'创建时间'},
        		{field:'-',title:'操作',align:'center',formatter:function(v,r,i){
        			var action = '<a href="#" onclick="openAudit('+r.id+');">去审核</a>&nbsp;&nbsp;';
					return action;
				}}
    		]],
    		view: detailview,
    	    detailFormatter: function(rowIndex, rowData){
    	        return '<table><tr>' +
    	                '<td rowspan=2 style="border:0,height:50px;">'+rowData.articleContent+'</td>' +
    	                '</tr></table>';
    	    }
		 });
		
		 //过滤条件参数
		function getItem(){
			var userName = $.trim($("#search_user").textbox("getValue"));
			var articleTitle = $.trim($("#search_articleTitle").textbox("getValue"));
			var articleType = $.trim($("#search_articleType").combobox("getValue"));
			var enabled = $.trim($("#search_enabled").combobox("getValue"));
			var searchItem = {};
			if(userName.length>0){
				searchItem.userName=userName;
			}
			if(articleTitle.length>0){
				searchItem.articleTitle=articleTitle;
			}
			if(articleType.length>0){
				searchItem.articleType=articleType;
			}
			if(enabled.length>0){
				searchItem.enabled=enabled;
			}
			return searchItem;
		}
		function handler() {
			switch(this.name) {
				case 'add': toAdd();break;
				case 'save_tag': saveTag();break;
			}
		}
		function toAdd() {
			show({code:'tag_info_add',title:'文章审核',iconCls:'icon-add',uri:'add',width:800,height:800,
				options : {
					success : function(data) { 
						$('#article_datagrid').datagrid('reload'); 
					}
				}
			});
		}

	
	$("#a_searchTag").click(function(){
		reloadDate();
	});
	$("#a_clearn").click(function(){
		resetData();
	});
		
		function reloadDate(){
			var item = getItem();
			$('#article_datagrid').datagrid({ queryParams: item});   //点击搜索
		}
		function resetData(){
			$("#search_user").textbox("setValue","");
			$("#search_articleTitle").textbox("setValue","");
			$("#search_articleType").combobox("setValue","");
			$("#search_enabled").combobox("setValue","");
			reloadDate();
		}
		
		
		
		
	});
	
	//去审核
	function openAudit(id){
		show({code:'tag_info_add',title:'文章审核信息',iconCls:'icon-add',uri:'goAudit?id='+id,width:800,height:820,
			options : {
				success : function(data) { 
					$('#article_datagrid').datagrid('reload'); 
				}
			}
		});
	}
	
	
</script>
</head>
<body>
	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'north',border:false">
			<fieldset>
    		<legend>过滤条件</legend>
    		<table style="width:100%">
    			<tr>
    				<td>文章标题:<input id="search_articleTitle" class="easyui-textbox" data-options="prompt:'请输入文章名称'" ></td>
    				<td>文章作者:<input id="search_user" class="easyui-textbox" data-options="prompt:'请输入作者'" ></td>
    				<td>
    					文章类型:
    					<select id="search_articleType" class="easyui-combobox" data-options="width:60,panelHeight:100">
    						<option></option>
    						<option value="1">文章</option>
    						<option value="3">音频</option>
    						<option value="5">视频</option>
    						<option value="7">话题pk</option>
    					</select>
    				</td>
    				<td>
    					是否可用:
    					<select id="search_enabled" class="easyui-combobox" name="enabled" data-options="width:50,panelHeight:60">
    						<option> </option>
    						<option value="1">是</option>
    						<option value="0">否</option>
    					</select>
    				</td>
    				<td><a id="a_searchTag" class="easyui-linkbutton" iconCls="icon-search">查询</a></td>
    				<td>
    					<a id="a_clearn" class="easyui-linkbutton" iconCls="icon-undo">清除</a>
    				</td>
    			</tr>
    		</table>
  		</fieldset>
		</div>
  		<div data-options="region:'center',border:false" style="padding-bottom: 33px">
            <div id="toolbar_articleTable" class="toolbar"></div>
  			<table id="article_datagrid"></table>
		</div>
		<div id="dialog_category" class="easyui-dialog" data-options="closed:true," title="审核投稿标签" style="width:500px;height:300px;padding:10px">
		<!-- 	
			<div id="tag_datagrid_toolbar" class="toolbar" ></div>
			<table id="tag_datagrid" style="height:80px" class="easyui-datagrid" data-options="rownumbers:true,singleSelect:true,tilte:'文章标签',method:'get'">
			</table>
			<table id="category_datagrid" style="height:80px" class="easyui-datagrid" data-options="rownumbers:true,singleSelect:true,title:'投稿专题',method:'get'">
			</table>
			 -->
			 
			 
		<div class="easyui-layout" style="width:350px;height:200px;">
			<div data-options="region:'east' " style="width:100px;">
				<table id="category_datagrid" style="width:100px;height:80px" class="easyui-datagrid" data-options="rownumbers:true,singleSelect:true,title:'投稿专题',method:'get'">
				</table>
			</div>
			<div data-options="region:'center' " style="width:100px;">
				<table id="tag_datagrid" style="width:100px;height:80px;" class="easyui-datagrid" data-options="rownumbers:true,singleSelect:true,tilte:'文章标签',method:'get'">
				</table>
			</div>
		</div>
			
			
			
			
		</div>
	</div>
</body>
</html>